using GameFramework.Event;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace TowerDefence_Zombie
{
    public class GuideCondition_SynthesisTower : GuideCondition_Base
    {
        private int targetSynthesisLevel;

        public GuideCondition_SynthesisTower(DRGuideCondition conditionInfo, Action conitionCompleteClick)
            : base(conditionInfo, conitionCompleteClick)
        {
            targetSynthesisLevel = conditionInfo.ConditionParams_Int;
        }

        public override void StartCondition()
        {
            base.StartCondition();
            GameEntry.Event.Subscribe(SynthesisTowerEventArgs.EventId, OnSynthesisTower);
        }

        private void OnSynthesisTower(object sender, GameEventArgs e)
        {
            SynthesisTowerEventArgs ne = (SynthesisTowerEventArgs)e;
            if (ne == null)
                return;

            if (ne.TowerLevel >= targetSynthesisLevel)
            {
                IsCompleteFlag = true;
            }
        }

        public override void Dispose()
        {
            GameEntry.Event.Unsubscribe(SynthesisTowerEventArgs.EventId, OnSynthesisTower);
            base.Dispose();
        }

    }
}
